package com.example.battle.entity;

import androidx.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;

@Entity
public class User implements Serializable {
    @NonNull
    @PrimaryKey
    @ColumnInfo(name = "user_id")
    private String userId;// 用户账号
    @ColumnInfo(name = "user_name")
    private String userName;// 用户名称
    @ColumnInfo(name = "region")
    private String region;;// 用户年龄
    @ColumnInfo(name = "gender")
    private int gender;// 性别
    @ColumnInfo(name = "password")
    private String password;// 密码
    @ColumnInfo(name = "birth")
    private String birth;// 生日
    @ColumnInfo(name = "portrait")
    private byte[] portrait;// 头像

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }


    public int getGender() {
        return gender;
    }

    public void setGender(int gender) {
        this.gender = gender;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getBirth() {
        return birth;
    }

    public void setBirth(String birth) {
        this.birth = birth;
    }

    public byte[] getPortrait() {
        return portrait;
    }

    public void setPortrait(byte[] portrait) {
        this.portrait = portrait;
    }

    public String getRegion() {
        return region;
    }

    public void setRegion(String region) {
        this.region = region;
    }

    //check是传入未MD5加密的
    public boolean checkPassword(String str){
        if (password.equals(str)) return true;
        else return false;
    }

    @Override
    public String toString() {
        return "User{" +
                "userId='" + userId + '\'' +
                ", userName='" + userName + '\'' +
                ", region='" + region + '\'' +
                ", gender=" + gender +
                ", password='" + password + '\'' +
                ", birth=" + birth +
                ", portrait=" + Arrays.toString(portrait) +
                '}';
    }

}
